package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.dto.LuntaiStoreExcel;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LuntaiStore;
import com.ruoyi.system.service.ILuntaiStoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 门店信息Controller
 *
 * @author ruoyi
 * @date 2025-02-17
 */
@RestController
@RequestMapping("/system/store")
public class LuntaiStoreController extends BaseController {
    @Autowired
    private ILuntaiStoreService luntaiStoreService;

    /**
     * 查询门店信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(LuntaiStore luntaiStore) {
        startPage();
        List<LuntaiStore> list = luntaiStoreService.selectLuntaiStoreList(luntaiStore);
        return getDataTable(list);
    }

    @GetMapping("/list2")
    public AjaxResult list2(LuntaiStore luntaiStore) {
        List<LuntaiStore> list = luntaiStoreService.selectLuntaiStoreList(luntaiStore);
        return AjaxResult.success(list);
    }

    /**
     * 导出门店信息列表
     */
    @Log(title = "门店信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LuntaiStore luntaiStore) {
        List<LuntaiStore> list = luntaiStoreService.selectLuntaiStoreList(luntaiStore);
        ExcelUtil<LuntaiStore> util = new ExcelUtil<LuntaiStore>(LuntaiStore.class);
        util.exportExcel(response, list, "门店信息数据");
    }



    /**
     * 获取门店信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return success(luntaiStoreService.selectLuntaiStoreById(id));
    }

    /**
     * 新增门店信息
     */
    @Log(title = "门店信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody LuntaiStore luntaiStore) {
        return toAjax(luntaiStoreService.insertLuntaiStore(luntaiStore));
    }

    /**
     * 修改门店信息
     */
    @Log(title = "门店信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody LuntaiStore luntaiStore) {
        return toAjax(luntaiStoreService.updateLuntaiStore(luntaiStore));
    }

    /**
     * 删除门店信息
     */
    @Log(title = "门店信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(luntaiStoreService.deleteLuntaiStoreByIds(ids));
    }


    /**
     * 导出门店信息列表
     */
    @Log(title = "导出门店列表", businessType = BusinessType.EXPORT)
    @PostMapping("/exportStoreList")
    public void exportInstallList(HttpServletResponse response, LuntaiStore luntaiStore) {
        List<LuntaiStoreExcel> list = luntaiStoreService.selectLuntaiStoreList2(luntaiStore);
        ExcelUtil<LuntaiStoreExcel> util = new ExcelUtil<LuntaiStoreExcel>(LuntaiStoreExcel.class);
        util.exportExcel(response, list, "门店信息数据");
    }

}
